<?php



function creerCP($id)
{
    include 'connexion (2).php';
    $wr="";
            $req_c1="select * from personne as p, stage as s, eleve as e, entreprise as ent where ent.IDENTREPRISE=s.IDENTREPRISE AND p.IDPERSONNE=e.IDELEVE AND e.IDELEVE=s.IDELEVE AND IDSTAGE=".$id;
            $connexion->exec("SET CHARACTER SET utf8");    
            $resu_cr1=$connexion->query($req_c1);
                if ($rep1=$resu_cr1->fetch(PDO::FETCH_ASSOC))
                {
                    $nomE=$rep1["NOMENTREPRISE"];
                    $nom=$rep1["NOMPERSONNE"];
                    $pnom=$rep1["PRENOMPERSONNE"];
                    $dated=$rep1["DATEDEBUT"];
                    $d=  mDateN($dated);

                    $wr="<center style='font-size:100%; border: 0px solid black; color:blue;' >Stage chez : ".$nomE."</center><br><br>";
                    //$wr+="Nom : ".$rep1["IDPERSONNE"]."<br>";
                    $wr=$wr."<center style='font-size:100%; color:blue;' ><i style='color:blue;'>Nom : ".$rep1["NOMPERSONNE"]."<br>";
                    $wr=$wr."Prénom : ".$rep1["PRENOMPERSONNE"]."<br>";
                    $wr=$wr."Sujet : ".$rep1["SUJETSTAGE"]."<br>";
                    $wr=$wr."Date début : ".$rep1["DATEDEBUT"]."<br>";
                    $wr=$wr."Date fin : ".$rep1["DATEFIN"]."</i></center><br><br><br><br>";
                }
                  
    
              $req_ac1="select * from compterendu where IDSTAGE=".$id." order by DATESAISIE";
                  $resu_a1=$connexion->query($req_ac1);
                  while ($repac=$resu_a1->fetch(PDO::FETCH_ASSOC))
                  {
                     $wr=$wr."<table class='tabcom'  ><tr style='border:3px #555;'><td>Le ".mDateN($repac['DATESAISIE'])."<br><br>
                     ".$repac['CORPS']."<br></td></tr></table>________________________________________________________";
                            
                                
                  }  
                   //echo $wr;
     
     
    
     $fp = fopen('telechargement/compteRendu/'.$nom.' '.$pnom.'-stage-du-'.$d.'.doc', 'w');
fwrite($fp, $wr);
fclose($fp);




}
/* */
function tel($id)
{
     include 'connexion (2).php';
     
    $req_c1="select * from personne as p, stage as s, eleve as e, entreprise as ent where ent.IDENTREPRISE=s.IDENTREPRISE AND p.IDPERSONNE=e.IDELEVE AND e.IDELEVE=s.IDELEVE AND IDSTAGE=".$id;
                $resu_cr1=$connexion->query($req_c1);
                if ($rep1=$resu_cr1->fetch(PDO::FETCH_ASSOC))
                {
                    $nomE=$rep1["NOMENTREPRISE"];
                    $nom=$rep1["NOMPERSONNE"];
                    $pnom=$rep1["PRENOMPERSONNE"];
                    $dated=$rep1["DATEDEBUT"];
                    $d=  mDateN($dated);
                }
    
    $tel='telechargement/compteRendu/'.$nom.' '.$pnom.'-stage-du-'.$d.'.doc';
    return $tel;
}
  
 //header("Location:compteRendu.php?id=".$id);
        
 function mDateN($d)
{
    if($d!="")
    {
    list($annee, $mois, $jour) = explode("-", $d); 
    list($j) = explode(" ", $jour);
   
                        /*$h=date("H");
                        $min=date("m",$d);
                        $s=date("s",$d);
                        $jour1=date("d",$d);
                        $m1=date("M",$d);
                        $annee1=date("Y",$d);*/
    $dateRet=$j." ".$mois." ".$annee;
    }else{$dateRet="";}
    return $dateRet;
}               
                
?>
